<template>
 <div>
 <city-header></city-header>
 <city-search :cities="allCities"></city-search>
 <city-list :allCities="allCities" :hotCities="hotCities" :letter="Letter"></city-list>
 <city-alphabet :allCities="allCities" @change="handleLetterChange"></city-alphabet>
 </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/CityHeader'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'

export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      allCities: {},
      hotCities: [],
      Letter: ''
    }
  },
  methods: {
    getCityinfo () {
      axios.get('/mock/city.json').then(res => {
        res = res.data
        if (res.ret && res.data) {
          const data = res.data
          this.allCities = data.Cities
          this.hotCities = data.HotCities
        }
      })
    },
    handleLetterChange (Letter) {
      this.Letter = Letter
    }
  },
  mounted () {
    this.getCityinfo()
  }
}

</script>

<style lang="stylus" scoped>

</style>
